package io.renren.modules.task.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.task.entity.MtCcAgvCommunLogEntity;
import io.renren.modules.task.service.MtCcAgvCommunLogService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;


/**
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-04-23 09:03:44
 */
@RestController
@RequestMapping("generator/mtccagvcommunlog")
public class MtCcAgvCommunLogController {
    @Autowired
    private MtCcAgvCommunLogService mtCcAgvCommunLogService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("generator:mtccagvcommunlog:list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = mtCcAgvCommunLogService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("generator:mtccagvcommunlog:info")
    public R info(@PathVariable("id") Integer id) {
        MtCcAgvCommunLogEntity mtCcAgvCommunLog = mtCcAgvCommunLogService.getById(id);


        return R.ok().put("mtCcAgvCommunLog", mtCcAgvCommunLog);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:mtccagvcommunlog:save")
    public R save(@RequestBody MtCcAgvCommunLogEntity mtCcAgvCommunLog) {
        mtCcAgvCommunLogService.save(mtCcAgvCommunLog);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:mtccagvcommunlog:update")
    public R update(@RequestBody MtCcAgvCommunLogEntity mtCcAgvCommunLog) {
        mtCcAgvCommunLogService.updateById(mtCcAgvCommunLog);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:mtccagvcommunlog:delete")
    public R delete(@RequestBody Integer[] ids) {
        mtCcAgvCommunLogService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
